centos7 MariaDB 升级到最新版本

1.创建/etc/yum.repos.d/MariaDB.repo文件, 下面以 10.0 版为例

1
2
3
4
5
6
7
8
9
[mariadb]

name = MariaDB

baseurl = http://yum.mariadb.org/10.0/centos6-amd64/

gpgkey = https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

gpgcheck = 1

2.关闭并卸载旧版本的mariadb,安装新版本的mariadb。

1
2
3
4
5
6
7
systemctl stop mariadb

yum remove mariadb-server mariadb mariadb-libs

yum clean all

yum install MariaDB-server MariaDB-client

3.自定义数据目录和服务端口,移除默认的数据目录,创建新的数据目录。

1
2
3
rm -rf /var/lib[mysql

mkdir /var/data/db/mariadb

4.修改配置文件/etc/my.cnf.d/mysql-clients.cnf,重点是[client],其他的可以参考

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
[client]

port = 3307

socket = /var/data/db/mariadb/mysql.sock

[mysql]

no-auto-rehash

[mysqldump]

quick

max_allowed_packet = 64M

[myisamchk]

key_buffer_size = 128M

sort_buffer_size = 128M

read_buffer = 2M

write_buffer = 2M

[mysqlhotcopy]

interactive-timeout

5.修改配置文件/etc/my.cnf.d/server.cnf,这里的性能参数来自my-large.ini文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
[mysqld]

port = 3307

datadir = /var/data/db/mariadb

socket = /var/data/db/mariadb/mysql.sock

skip-external-locking

key_buffer_size = 256M

max_allowed_packet = 64M

table_open_cache = 256

sort_buffer_size = 1M

read_buffer_size = 1M

read_rnd_buffer_size = 4M

myisam_sort_buffer_size = 64M

thread_cache_size = 8

query_cache_size= 16M

thread_concurrency = 8

log-bin=mysql-bin

binlog_format=mixed

server-id = 1

6.初始化数据

1
mysql_install_db --defaults-file=/etc/my.cnf --datadir=/var/data/db/mariadb/ --user=mysql

7.启动服务

1
systemctl restart mysql

8.设置ROOT密码

1
mysqladmin -u root password "8888888"

9.登陆mysql

1
mysql -uroot -p

10.授权root远程登录

root可从任何IP登陆,注意修改密码:’888888’

1
2
3
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '888888' WITH GRANT OPTION;

mysql>FLUSH RIVILEGES;

root可从指定IP登陆,注意修改密码:’888888’、IP:’192.168.1.188’

1
2
3
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.188' IDENTIFIED BY '888888' WITH GRANT OPTION;

mysql>FLUSH RIVILEGES;
关注作者公众号,获取更多资源!
赏作者一杯咖啡~